#include <Unit.h>
#include <iostream>

Unit::Unit(const std::string& name, unsigned int factor, const Unit *referenceUnit)
    : name(name)
    , factor(factor)
    , referenceUnit(referenceUnit)
{
}

unsigned int Unit::toBase() const
{
    return (referenceUnit != 0) ? this->factor * referenceUnit->toBase() : this->factor;
}

std::string Unit::toString() const
{
    return name;
}

std::string Unit::toBaseString() const
{
    return (referenceUnit != 0) ? referenceUnit->toBaseString() : name;
}

const Unit* Unit::nextUnit() const
{
    return referenceUnit;
}
